package com.study.controller;

import com.study.dao.entity.MovieUser;
import com.study.feign.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MovieUserController {
	
	@Autowired
	UserFeignClient userFeignClient;

	@Async
	@GetMapping("/feign/{id}")
	public MovieUser selectById(@PathVariable("id") int id) {


		for(int i=0; i<15; i++) {
			Thread t  = new Thread(new Runnable() {
				@Override
				public void run() {
					MovieUser movieUser =  userFeignClient.selectById(id);
					System.out.println(" " + Thread.currentThread().getName() + ": " + movieUser);

				}
			},"thread " + i);
			t.start();
		}
		return new MovieUser().setId(1);


//		MovieUser movieUser =  userFeignClient.selectById(id);
//		return movieUser;
	}
	
}
